//
//  HotInformationViewModel.m
//  MoXiProject
//
//  Created by 沈晨宇 on 2017/7/18.
//  Copyright © 2017年 周筱雯. All rights reserved.
//

#import "HotInformationViewModel.h"
#import "HotInformationModel.h"

@implementation HotInformationViewModel
- (instancetype)init
{
    self = [super init];
    if (self) {
        self.noticeArrayList = [[NSMutableArray alloc] initWithCapacity:0];
        
    }
    return self;
}
-(RACSignal *)noticeListResultRequestParameter:(LoadType)loadType
{
    return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
        
        self.page +=10;
        NSDictionary * parma = @{@"pageNo"     :[NSString stringWithFormat:@"0"],
                                 @"pageSize"   :[NSString stringWithFormat:@"%ld",self.page],
                                 @"typeId"    :[NSString stringWithFormat:@"5"]};
        
        [ScyRequestOperationManager noticeListParametersDic:parma success:^(NSDictionary *result) {
            
            if (result) {
                
                if (loadType == LoadData) {
                    [self.noticeArrayList removeAllObjects];
                }
                
                [self.noticeArrayList addObjectsFromArray:(NSMutableArray *)[MTLJSONAdapter modelsOfClass:[HotInformationModel class] fromJSONArray:result[@"result"] error:nil]];
                
            }
            
            [subscriber sendNext:result];
            [subscriber sendCompleted];
            
            
        } failture:^(id result) {
            
            [self.noticeArrayList removeAllObjects];
            [subscriber sendError:result];
        }];
        
        return nil;
    }];
}
@end
